<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title></title>
</head>
<body>
	<script type="text/javascript">
		// 1.字面量写法
		//   var expression =  /pattern/flags;
		/* var str = 'mjj';
		var p = /mjj/g;
		// console.log(p.test(str));
		if(p.test(str)){
			console.log('输入正确');
		}else{
			console.log('输入错误');
		}
		// 2.构造函数写法
		// RegExp
		var str2 = 'alexdsb';
		var p1 = new RegExp('alex','g');
		// test()检验匹配的规则是否符合,如果符合返回true
		console.log(p1.test(str2));
		
		// 元字符 一定要理解人家规则(规律)
		var str3 = 'hello world';
		console.log(/world$/g.test(str3));
		
		console.log(/(https|http):\/{2}w{3}\.(baidu|google|mi|apeland)\.(com|cn)/g.test('http://www.apeland.cn'));
		console.log(RegExp.$2); */
		// var re = /l/g;
		// console.log(re.test('hello'));
		// console.log(re.exec('heo'));
		// var str = 'hello wolrd';
		// console.log(str.match(re));
		// console.log(str.search(re));
		
		var timeStr = '2019.09.20';
		console.log(timeStr.replace(/\./g,'-'));
		
		
		
		
	</script>
</body>
</html>